﻿@{ Layout = null;}
@model MerchantTribeStore.Models.PagerViewModel
@helper IsCurrent(int page)
{
    if (Model.CurrentPage == page)
    {
        <text>current</text>
    }
}           
@helper RenderPager() 
{     
    int pages = Model.TotalPages;
<div class="pager">    
    <ul> 
        <li><a href="@String.Format(Model.PagerUrlFormatFirst, 1)">|&lt;</a></li>
        @if (Model.CurrentPage > 1) 
        { 
            <li><a href="@String.Format(Model.PagerUrlFormat, Model.CurrentPage - 1)">&laquo;</a></li> 
        } 
        else         
        { 
            <li class="inactive">&nbsp;</li> 
        }       
    @for (int i = 1; i <= pages; i++) 
    {         
        <li class="@IsCurrent(i)">        
        @if (i == 1)
        { 
            <a href="@String.Format(Model.PagerUrlFormatFirst, i)">@i</a>
        }
        else
        {
            <a href="@String.Format(Model.PagerUrlFormat, i)">@i</a>
        }
        </li>
    }   
        @if (Model.CurrentPage < pages)
        { 
            <li><a href="@String.Format(Model.PagerUrlFormat, Model.CurrentPage + 1)">&raquo;</a></li> 
        }
        else
        { 
            <li class="inactive">&nbsp;</li> 
        } 
        <li><a href="@String.Format(Model.PagerUrlFormat, pages)">&gt;|</a></li> 
    </ul> 
</div>    
} 
@if (Model.TotalPages > 1)
{
    @RenderPager() 
}
           

